<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="crm.model.Material" %>
<%@ page import="crm.control.MaterialControl"%>
<%@ page import="crm.util.ParamUtil" %>
<%@ page import="com.jspsmart.upload.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>    
    <title>My JSP 'resources_download_chuli.jsp' starting page</title>
  </head>
  
  <body>
<%
	request.setCharacterEncoding("UTF-8");
//	String id=request.getParameter("id");
	int id = ParamUtil.getInt(request, "id");
	Material material = new Material();
    MaterialControl mc = new MaterialControl();
    material = mc.getMaterialInformation(id);
//    System.out.println(resources.getDownloadtimes());
	SmartUpload mySmartdownload = new SmartUpload();
	String downfile="resources/resources/"+request.getParameter("downfile");
	try {
		response.reset();
		out.clear();
		out = pageContext.pushBody();
		mySmartdownload.initialize(pageContext);
		mySmartdownload.setContentDisposition(null);
		mySmartdownload.downloadFile(downfile);

	} catch(Exception e) {
		String errors="<li>文件下载失败：请检查选择的文件是否存在？</li>";
		request.setAttribute("errors",errors);
		RequestDispatcher rd=request.getRequestDispatcher("../material/material.jsp");
		rd.forward(request,response);
	}
%>    
  </body>
</html>
